package com.szdvte.news.dao.impl;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.szdvte.news.bean.Comments;
import com.szdvte.news.dao.ICommentsDao;

public class CommentsDaoImpl extends BaseDaoImpl implements ICommentsDao {

	@SuppressWarnings("unchecked")
	@Override
	public List<Comments> selectComments(Comments comments) {
		List<Comments> list = new ArrayList<Comments>();
		try {
			list = getSqlMapClient().queryForList("comments.select",comments);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return list;
	}

	@Override
	public boolean add(Comments comments) {
		boolean flag = false;
		try {
			getSqlMapClient().insert("comments.add", comments);
			flag = true;
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return flag;
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Comments> selectAll(Comments comments) {
		List<Comments> list = new ArrayList<Comments>();
		try {
			list = getSqlMapClient().queryForList("comments.selectAll",comments);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return list;
	}

	@Override
	public boolean delete(Comments comments) {
		boolean flag = false;
		try {
			getSqlMapClient().update("comments.delete",comments);
			return true;
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return flag;
	}

}
